//
//  REHelpTwoTableViewCell.m
//  录音
//
//  Created by ywy on 2016/12/23.
//  Copyright © 2016年 Wely. All rights reserved.
//

#import "REHelpTwoTableViewCell.h"

@interface REHelpTwoTableViewCell ()<UITextFieldDelegate,UITextViewDelegate>

@end

@implementation REHelpTwoTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.feedbackTextView.layer.borderColor = RERGBColor(234, 234, 234).CGColor;
    self.feedbackTextView.delegate  = self;
    self.feedbackTextView.text = @"请输入你的问题";
    self.feedbackTextView.textColor = RERGBColor(210, 210, 210);
    
    self.phoneTextField.delegate = self;
    self.phoneTextField.layer.cornerRadius = 5;
    self.phoneTextField.layer.borderColor =RERGBColor(234, 234, 234).CGColor;
    self.phoneTextField.layer.borderWidth = 1.0;
    
    UIView *blankView = [[UIView alloc] initWithFrame:CGRectMake(self.phoneTextField.frame.origin.x,self.phoneTextField.frame.origin.y,5.0, self.phoneTextField.frame.size.height)];
    self.phoneTextField.leftView = blankView;
    self.phoneTextField.leftViewMode =UITextFieldViewModeAlways;
    // Initialization code
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}
-(void)textFieldDidEndEditing:(UITextField *)textField{
    if ([self.delegate respondsToSelector:@selector(phoneStr:)]) {
        [self.delegate phoneStr:[NSString stringWithFormat:@"%@",textField.text]];
    }
}
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if ([string isEqualToString:@"\n"]){ //判断输入的字是否是回车，即按下return
        //在这里做你响应return键的代码
        [textField resignFirstResponder];
        return NO; //这里返回NO，就代表return键值失效，即页面上按下return，不会出现换行，如果为yes，则输入页面会换行
    }
//    textField.textColor = RERGBColor(210, 210, 210) ;
    
    if ([self.delegate respondsToSelector:@selector(phoneStr:)]) {
        [self.delegate phoneStr:[NSString stringWithFormat:@"%@",[textField.text stringByAppendingString:string]]];
    }
    return YES;

}


-(void)textViewDidBeginEditing:(UITextView *)textView
{
    if ([textView.text isEqualToString:@"请输入你的问题"]) {
        textView.text = @"";
        textView.textColor = [UIColor blackColor];
    }
}
-(void)textViewDidEndEditing:(UITextView *)textView
{
    if (textView.text.length == 0) {
        textView.text = @"请输入你的问题";
        textView.textColor = RERGBColor(210, 210, 210);
    }else
    {
        if ([self.delegate respondsToSelector:@selector(questStr:)]) {
            [self.delegate questStr:textView.text];
        }
    }
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
    if ([text isEqualToString:@"\n"]){ //判断输入的字是否是回车，即按下return
        //在这里做你响应return键的代码
        [textView resignFirstResponder];
        return NO; //这里返回NO，就代表return键值失效，即页面上按下return，不会出现换行，如果为yes，则输入页面会换行
    }
    if ([self.delegate respondsToSelector:@selector(questStr:)]) {
        [self.delegate questStr:[textView.text stringByAppendingString:text]];
    }
    return YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
